Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
bnf-parser
Advanced tools
A simple library to parse input strings into token trees based on a BNF's description.
BNF trees must first be compiled before they can be used to parse syntax trees.
let result = BNF.parse(file, BNF.syntax);
let tree = BNF.compile(result.tree);
A compiled BNF can be saved as a JSON file and reloaded later
// Store the compiled result for later use
fs.writeFileSync(path, JSON.stringify(tree));
// Load the compiled BNF
let tree = BNF.fromJSON(
JSON.parse( fs.readFileSync(path, 'utf8') )
);
Running parse will return a BNF_Parse
object, which contains a tree structure of BNF_SyntaxNode
s. How these nodes are structured depends on the compiled BNF used to parse the syntax.
Provided with BNF data, this will return a BNF_Tree with error handling.
The BNF used by this application is a dilect of regular extensions for BNF. Most noteably it adds the not (!
) opperator.
The BNF outlining the syntax of BNFs used by this system can be found here.
The not operator must be before a set of brackets, and will consume characters until either the quota is met, or the pattern within the brackets successfully matches.
The quota of the not operation can be defined the same was as constants and terms via the use of +
, *
, ?
operators.
FAQs
Deterministic BNF compiler/parser
The npm package bnf-parser receives a total of 7,212 weekly downloads. As such, bnf-parser popularity was classified as popular.
We found that bnf-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.